package com.wang.ymcc.service.impl;

import com.wang.lwm.dto.StationInMQDto;
import com.wang.ymcc.domain.MessageStation;
import com.wang.ymcc.mapper.MessageStationMapper;
import com.wang.ymcc.service.IMessageStationService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author whale
 * @since 2022-10-22
 */
@Service
public class MessageStationServiceImpl extends ServiceImpl<MessageStationMapper, MessageStation> implements IMessageStationService {

    @Override
    public void save(StationInMQDto stationInMQDto) {
        List<Long> ids = stationInMQDto.getIds();
        Date date = new Date();
        /*
            insert into table(...) values（），（），（）
         */
        ids.forEach(id->{
            MessageStation station = new MessageStation();
            station.setTitle(stationInMQDto.getTitle());
            station.setContent(stationInMQDto.getContent());
            station.setIsread(0);
            station.setUserId(id);
            station.setSendTime(date);
            station.setType(stationInMQDto.getType());
            insert(station);
        });

    }
}
